﻿CREATE VIEW dbo.VIEW_SEARCH_GUILD_BILL
AS
SELECT        dbo.GUILD_BILL.ID, dbo.GUILD_BILL.NUMBER, dbo.GUILD_BILL.PID, dbo.CONTRACT.NUMBER AS CONTRACT_NUM, 
                         dbo.NSI_ORGANIZATION.SHORT_NAME AS NSI_ORGANIZATION_SHORT_NAME, dbo.NSI_TYPE_OF_ACTIVITY.NAME AS NSI_TYPE_OF_ACTIVITY_NAME, 
                         dbo.GUILD_BILL.DATE
FROM            dbo.CONTRACT INNER JOIN
                         dbo.GUILD_BILL ON dbo.CONTRACT.PID = dbo.GUILD_BILL.PID LEFT OUTER JOIN
                         dbo.NSI_TYPE_OF_ACTIVITY ON dbo.CONTRACT.NSI_TYPE_OF_ACTIVITY_ID = dbo.NSI_TYPE_OF_ACTIVITY.ID LEFT OUTER JOIN
                         dbo.NSI_ORGANIZATION ON dbo.CONTRACT.NSI_ORGANIZATION_ID = dbo.NSI_ORGANIZATION.ID